package com.euq.mapper;

import com.euq.entity.Cfg;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CfgMapper {
    @Select("select * from cfg")
    List<Cfg> listAll();
    @Delete("delete * form cfg where id=#{id}")
    void deleteCfg(Long id);
    @Select("select * from cfg where cfg_name=#{cfgName}")
    Cfg getCfgByCfgName(String cfgName);
    @Insert({"insert into cfg (create_time,create_by,modify_time,modify_by,cfg_name,cfg_value,cfg_desc)",
            "values(now(),1,now(),1,#{cfgName},#{cfgValue},#{cfgDescription})"})
    void addCfg(String cfgName, String cfgValue, String cfgDescription);
    @Select("select * from cfg where id=#{id}")
    Cfg getCfgById(Long id);
    @Select({
            "<script>",
            "SELECT * FROM cfg",
            "<where>",
            "  <if test='cfgName != null and cfgName != \"\"'>",
            "    AND cfg_name = #{cfgName}",
            "  </if>",
            "  <if test='cfgValue != null and cfgValue != \"\"'>",
            "    AND cfg_value = #{cfgValue}",
            "   </if>",
            "</where>",
            "</script>"
    })
    List<Cfg> selectByConditions(@Param("cfgName")String cfgName,@Param("cfgValue") String cfgValue);
}
